<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.jieSuan.zhiFuDan"/> <spring:message code="message.jieSuan.yiLiaoJiGouFenZu"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.jieSuan.zhiFuDan"/></h1>
         <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success ">
            	<table class="jqgrid" id="firstGridlist"></table> 
            		<div id="firstGridpage"></div>
                <table class="jqgrid" id="secondGridlist"></table>
        </div>
         <div class="box-footer text-center">
                    <a href="toPaymentByNoComp.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
    </section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    $(function(){
		$("#firstGridlist").jqGrid(
				{   url : "getHospByNoCompList.html?compId=${compId}",
					mtype : "POST",
					datatype : "json",
					height :320,
					colNames : [
								'<spring:message code="message.listForm.yiLiaoJiGou"/>ID',
								'<spring:message code="message.listForm.yiLiaoJiGouBianMa"/>',
								'<spring:message code="message.listForm.yiLiaoJiGouMingCheng"/>',
								'<spring:message code="message.listForm.suoShuDiQu"/>',
								'<spring:message code="message.jieSuan.zhiFuYaoPinShu"/>',
								'<spring:message code="message.jieSuan.zhiFuZongJinE"/>',
								'<spring:message code="message.jieSuan.zhangHuYuE"/>'
					            ],
					colModel : [
								{name : 'hospId',index : 'settlementId', hidden : true,width : 160,align : "center",sortable:false},
								{name : 'hospCode',index : 'settlementCode', width : 160,align : "center",sortable:false},
								{name : 'hospName',index : 'settlementName', width : 160,align : "center",sortable:false,
									 formatter:function(cellvalue, options,row) {
									     if(cellvalue!=null){	
											 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.hospId+"','"+cellvalue+"','${ctx}/stdHospInfo/hospInfoDetail.html?hospId="+row.hospId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
										 }else{
											 return "";
										 }
									}	
								},
								{name : 'areaName',index : 'heaBurCode', width : 160,align : "center",sortable:false},
								{name : 'totalDrugs',index : 'heaBurName', width : 160,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										return "<a href='javascript:totalHosp(\""+row.hospId+"\");'>"+cellvalue+"</a>";
									}
								},
								{name : 'totalAmount',index : 'areaName', width : 100,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										return formatAmount(cellvalue, options, row);
									}
								},
								{name : 'outstandAmt',index : 'operate', width : 160,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										return formatAmount(cellvalue, options, row);
									}
								}
					],
					rownumbers : true,
					pager : "#firstGridpage",
					viewrecords : true,
					caption : "<spring:message code="message.jieSuan.yiLiaoJiGouFenZu"/><spring:message code="message.listForm.lieBiao"/>",
					//序号宽度自动变化
	                gridComplete:function(){
	                    //序号列宽度自适应（参数为jqgridID）
	                    autoRNWidth("firstGridlist");
	                    //数据只有一条时默认选中（参数为jqgridID）
	                    selectByOneData("firstGridlist");
	                },
					jsonReader : {
						repeatitems : false,
						id : "ids"
					}
				});
		$("#firstGridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
		
		$("#secondGridlist").jqGrid(
				{   url : "getDrugsDetailByNoCompList.html",
					mtype : "POST",
					datatype : "json",
					hiddengrid: true,
					height : 350,
					colNames : [
								'<spring:message code="message.listForm.yaoPinBianMa"/>',
								'<spring:message code="message.listForm.tongYongMing"/>',
								'<spring:message code="message.listForm.jiXing"/>',
								'<spring:message code="message.listForm.guiGe"/>',
								'<spring:message code="message.listForm.zhuanHuanXiShu"/>',
								'<spring:message code="message.listForm.baoZhuangDanWei"/>',
								'<spring:message code="message.listForm.caiZhi"/>',
								'<spring:message code="message.listForm.shengChanQiYe"/>',
								'<spring:message code="message.jieSuan.caiGouShuLiang"/>',
								'<spring:message code="message.listForm.CaiGouJinE"/>',
								'<spring:message code="message.jieSuan.zhiFuLeiXing"/>'
					            ],
					colModel : [
								{name : 'drugCode',index : 'settlementId', hidden : true,width : 160,align : "center",sortable:false},
								{name : 'drugName',index : 'settlementCode', width : 160,align : "center",sortable:false},
								{name : 'formName',index : 'settlementName', width : 160,align : "center",sortable:false},
								{name : 'specName',index : 'areaName', width : 100,align : "center",sortable:false},
								{name : 'factor',index : 'totalOrders', width : 100,align : "center",sortable:false},
								{name : 'unit',index : 'totalAmount', width : 100,align : "center",sortable:false},
								{name : 'materialName',index : 'submitUser', width : 160,align : "center",sortable:false},
								{name : 'prodName',index : 'submitUser', width : 160,align : "center",sortable:false},
								{name : 'proCount',index : 'submitUser', width : 160,align : "center",sortable:false},
								{name : 'proPrice',index : 'submitUser', width : 160,align : "center",sortable:false,
		                        	   formatter:function(cellvalue, options, row){
		                                   return formatAmount(cellvalue, options, row);
		                               }},
								{name : 'bankAcctTransType',index : 'submitUser', width : 160,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										var temp ='';
										if (cellvalue==1) {
											temp = "<spring:message code="message.jieSuan.caiGouLei"/>";
										}else if (cellvalue==2) {
											temp = "<spring:message code="message.jieSuan.tuiHuoLei"/>";
										}else{
											temp ='<spring:message code="message.listForm.qiTa"/>';
										}
										return temp;
									}
								}
					],
					rownumbers : true,
					pager : "#gridpage",
					viewrecords : true,
					caption : "<spring:message code="message.jieSuan.yaoPinFenZu"/><spring:message code="message.listForm.lieBiao"/>",
					//序号宽度自动变化
	                gridComplete:function(){
	                    //序号列宽度自适应（参数为jqgridID）
	                    autoRNWidth("secondGridlist");
	                    //数据只有一条时默认选中（参数为jqgridID）
	                    selectByOneData("secondGridlist");
	                },
					jsonReader : {
						repeatitems : false,
						id : "ids"
					}
				});
		$("#secondGridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
		$(window).trigger("resize");
    });
    
    
    function totalHosp(hospId){
	        $("#secondGridlist").jqGrid('setGridParam',{
                datatype:'json',
                postData:{'hospId':hospId},
                page : 1
            }).trigger("reloadGrid"); 
		    $(".ui-icon").click();
    }
    
    function CurentTime(now)  
	{       	         
	    var year = now.getFullYear();   
	    var month = now.getMonth() + 1; 
	    var day = now.getDate();     
	    var hh = now.getHours();       
	    var mm = now.getMinutes(); 
	    var ss=now.getSeconds(); 
	    var clock = year + "-"; 
	    if(month < 10) clock += "0";         
	    clock += month + "-";  
	    if(day < 10) clock += "0";   
	    clock += day + " "; 		
	    return(clock);   
	}
 </script>
</body>
</html>